
[HEADER]
	VERSION		01.00.00.00
	DESCRIPTION Cell Shading Example
	COPYRIGHT	Imagination Technologies Ltd.
[/HEADER]

[TEXTURES]
	// NO TEXTURES USED
[/TEXTURES]

[VERTEXSHADER] 
	NAME 		MyVertexShader 

	[GLSL_CODE]
		attribute vec4	myVertex;
		attribute vec3	myNormal;
		uniform mat4	myWVPMatrix;
		uniform mat3	myWorldViewIT;
		
		varying float intensity;
		
		void main(void)
		{
			gl_Position = myWVPMatrix * myVertex;
			vec3 normal = normalize(myWorldViewIT * myNormal);
			intensity = abs( dot(vec3(0.0,0.0,1.0), normal) );
			intensity = max(intensity, 0.0);
		}
	[/GLSL_CODE]
[/VERTEXSHADER]
    
[FRAGMENTSHADER] 
	NAME 		MyFragmentShader 

	[GLSL_CODE]
		varying float intensity;

		void main (void)
		{
			vec4 color;
			
			if (intensity > 0.95)
				color = vec4(1.0,0.5,0.5,1.0);
			else if (intensity > 0.5)
				color = vec4(0.6,0.3,0.3,1.0);
			else if (intensity > 0.25)
				color = vec4(0.4,0.2,0.2,1.0);
			else
				color = vec4(0.2,0.1,0.1,1.0);
 			gl_FragColor = color;
		}
	[/GLSL_CODE]
[/FRAGMENTSHADER]
 
[EFFECT] 
	NAME 	ToonEffect

	UNIFORM	myWorldViewIT	WORLDVIEWIT
	UNIFORM	myWVPMatrix		WORLDVIEWPROJECTION

	ATTRIBUTE	myVertex	POSITION
	ATTRIBUTE	myNormal	NORMAL

	VERTEXSHADER MyVertexShader
	FRAGMENTSHADER MyFragmentShader
[/EFFECT]
